
var visa = RegExp(r'^(?:4[0-9]{12}(?:[0-9]{3})?)$');
var visa_in_text = RegExp(r'\b4[0-9]{12}(?:[0-9]{3})?\b');
var input = '4457418557635128';
var text = 'Does this text mention a VISA 4457418557635128 number?';

main(List<String> args){
  print(visa.pattern);

  // 是否匹配
  if(visa.hasMatch(input)){
    print('Could be a VISA number');
  }


  // 是否包含
  if(input.contains(visa)){
    print('Could be a VISA number');
  }

  // 查出所有的匹配项
  var matches = visa_in_text.allMatches(text);
  for(var m in matches){
    print(m.group(0));
  }

  visa_in_text.allMatches(text).forEach((m) => print(m[0]));


  print(text.replaceAll(visa_in_text, 'XXXXXXXXXXXXXXXX'));
  // 大小写敏感
  print(visa.isCaseSensitive);
  // 是否多行
  print(visa.isMultiLine);


}